const http = (url,data={},method='GET') => {
  method = method.toUpperCase()
  return new Promise((resolve,reject)=>{
    wx.request({
      url: url,
      data,
      method,
      header:{
        'content-type':method === 'POST' ? 'application/x-www-form-urlencoded' : 'application/json'
      },
      success:res=>{
        resolve(res)
      },
      fail:err=>{
        reject(err)
      }
    })
  })
}

module.exports = {
  http
}